package com.retailshop.shopuser.WapUserController;


import com.retailshop.shopuser.entity.LeaveMessage;
import com.retailshop.shopuser.service.LeaveMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
@CrossOrigin
@Controller
@RequestMapping("/wap")
public class LeaveMessageController {


    @Autowired
    LeaveMessageService leaveMessageService;

    @ResponseBody
    @RequestMapping("/getMessage")
    public String getMessage(){

        LeaveMessage leaveMessage=new LeaveMessage();
        leaveMessage.setUserNoId(77300);
        leaveMessage.setLeaveTime(new Timestamp(System.currentTimeMillis()));
        leaveMessage.setLeaveMessageContent("测试时间问题");
        leaveMessage.setUserMessagesId(1);

        int row=leaveMessageService.insertSelective(leaveMessage);
        if(row>0){
            int leaveId=leaveMessage.getLeaveId();
            leaveId=13;
           LeaveMessage leaveMessage1= leaveMessageService.selectByPrimaryKey(leaveId);
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Date date=new Date(leaveMessage1.getLeaveTime().getTime());
            String d=sdf.format(date);
            System.out.println("----留言---->"+d);
            return d;
        }

    return "";
    }


}
